package a12;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class A12 {


    interface Animal{
        public void eat();

        public int fly();
    }

    static class Target implements Animal{

        @Override
        public void eat() {
            System.out.println("eating...");
        }

        @Override
        public int fly() {
            System.out.println("flying...");
            return 0;
        }
    }

    public static void main(String[] args) {
        Target target = new Target();
        Animal proxy = ((Animal) new $Proxy0(new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                System.out.println("before...");
                Object result = method.invoke(target);
                System.out.println("after...");
                return result;
            }
        }));
        proxy.eat();
        proxy.fly();
    }
}
